﻿@{
    ViewBag.Title = "DeskWork";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@using Common.BaseLibrary.Authorization
@using DepartmentWork.Model
@model DepartmentWork.Model.ProjectDeskWorkState



<div class="page-header">
    <div class="pull-left">
        <ol class="breadcrumb visible-sm visible-md visible-lg">
            <li><a href="index.html"><i class="icon fa fa-home"></i>主页</a></li>
            <li class="active"><a href="#"><i class="fa fa-envelope"></i>科室管理</a></li>
        </ol>
    </div>
</div>
@{
    if (ViewBag.Flag == "True")
    {
    <div class="alert alert-success">
        <button type="button" class="close" data-dismiss="alert">×</button>
        <strong>&emsp;@ViewBag.FlagInfo！</strong>
    </div>
    }
    if (ViewBag.Flag == "False")
    {
    <div class="alert alert-danger">
        <button type="button" class="close" data-dismiss="alert">×</button>
        <strong>&emsp;操作失败！</strong> @ViewBag.FlagInfo
    </div>
    }
}
<style>
   ul>.active {
       font-weight:bold
   }
   .bootstrap-select  {
       width: 100%;
   }
    
</style>

<div class="row">
    <div class="col-lg-12">
        <div class="panel">
            <div class="panel-heading bk-bg-primary">
                <h6><i class="fa fa-table red"></i><span class="break"></span>科室工作</h6>

                @if (ViewBag.IsAdmin == true)
                {
                    <div class="panel-actions">
                        <a data-toggle="modal" data-target="#myModal" class="bk-margin-5 btn btn-default  btn-sm" style="background-color: #ECEDF0">&nbsp;&nbsp;新工作发布&nbsp;&nbsp;</a>
                    </div>
                }
            </div>
            <div class="panel-body">
                <div class="tabs">
                    <ul class="nav nav-tabs">
                        <li class="active">
                            <a href="#overview"style="color:black" data-toggle="tab">未完成</a>
                        </li>
                        <li class="">
                            <a href="#edit"style="color:black" data-toggle="tab">已完成</a>
                        </li>
                        @if (ViewBag.PAN==true)
                        {
                        <li class="">
                            <a href="#dai"style="color:black" data-toggle="tab">代办工作</a>
                        </li> 
                        }
                      
                    </ul>
                    <div class="tab-content">
                        <div id="overview" class="tab-pane active">
                            <div class="panel-body">
                                <div class="table-responsive">
                                    <table class="table table-hover">
                                        
                                        <thead>
                                            <tr>
                                                <th style="text-align: center">工作编号</th>
                                                <th style="text-align: center">工作名称</th>
                                                <th style="text-align: center">创建日期</th>
                                                <th style="text-align: center">完成期限</th>
                                                <th style="text-align: center">发布人</th>
                                                <th style="text-align: center">负责人</th>
                                                 <th style="text-align: center">工作状态</th>
                                                   <th style="text-align: center">是否提交</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            @{
                                                if (this.Model.DeskWorkNo.Tables[0].Rows.Count != 0)
                                                {
                                                    for (int i = 0; i < this.Model.DeskWorkNo.Tables[0].Rows.Count; i++)
                                                    {
                                                        var item = this.Model.DeskWorkNo.Tables[0].Rows[i];
                                                <tr>
                                                    <td style="text-align: center;color:black">@item["DESKWORK_NO"]</td>

                                                    @if (ViewBag.IsAdmin == true)//团队负责人
                                                    {
                                                        <td style="text-align: center"><a style="color:blue" href="@Url.Action("CompileDeskWork", "DeskWork", new { area = "DepartmentArea", projectId = item["DESKWORK_ID"] })">@item["DESKWORK_NAME"]</a></td>
                                                    }
                                                     @if (ViewBag.IsAdmin == false && ViewBag.currentID.ToString() == item["DESKWORK_PRINCIPAL_ID"].ToString())//项目负责人
                                                    {
                                                            <td style="text-align: center"><a style="color:blue" href="@Url.Action("CompileDeskWork", "DeskWork", new { area = "DepartmentArea", projectId = item["DESKWORK_ID"] })">@item["DESKWORK_NAME"]</a></td>  
                                                    }
                                                     @if (ViewBag.IsAdmin == false && ViewBag.currentID.ToString() != item["DESKWORK_PRINCIPAL_ID"].ToString())//项目负责人
                                                    {
                                                            <td style="text-align: center;color:black">@item["DESKWORK_NAME"]</td>
                                                    }



                                                    @if (ViewBag.NIIsAdmin == false) //匿名用户
                                                    {
                                                         <td style="text-align: center;color:black">@item["DESKWORK_NAME"]</td>
                                                    }       

                                                    <td style="text-align: center;color:black">@Convert.ToDateTime(item["DESKWORK_CREATETIME"]).ToString("yyyy-MM-dd")</td>
                                                    <td style="text-align: center;color:black">@Convert.ToDateTime(item["DESKWORK_DEADINE"]).ToString("yyyy-MM-dd")</td>
                                                    <td style="text-align: center;color:black">@item["DESKWORK_FOUNDER"]</td>
                                                    <td style="text-align: center;color:black">@item["DESKWORK_PRINCIPAL"]</td>
                                                      @if (Convert.ToDateTime(item["DESKWORK_DEADINE"]).Subtract(DateTime.Now).Days > 3)
                                                      {
                                                         <td style="text-align:center;color:black"> <a href="#" title="工作正在办理"><img src="~/Assets/img/green_doing.gif"/> </a></td> 
                                                      }
                                                     @if (Convert.ToDateTime(item["DESKWORK_DEADINE"]).Subtract(DateTime.Now).Days >= 0 && Convert.ToDateTime(item["DESKWORK_DEADINE"]).Subtract(DateTime.Now).Days < 3)
                                                     {
                                                             <td style="text-align:center;color:black"><a href="#" title="剩余时间少于三天"><img src="~/Assets/img/yellew_three.gif"/> </a></td> 
                                                     }
                                                      @if (Convert.ToDateTime(item["DESKWORK_DEADINE"]).Subtract(DateTime.Now).Days < 0)
                                                      {
                                                              <td style="text-align:center;color:black"><a href="#" title="工作时间已经超期"><img src="~/Assets/img/red_over.gif"/> </a></td> 
                                                      }

                                                    @if (Convert.ToInt32(item["DESKWORK_EDITOR"]) == 1)
                                                    {
                                                              <td style="text-align: center ; color:red" >已提交</td>
                                                    }
                                                     @if (Convert.ToInt32(item["DESKWORK_EDITOR"]) == 2)
                                                     {
                                                              <td style="text-align: center;color:black">未提交</td>
                                                     }

                                                </tr>
                                                    }
                                                }
                                            }

                                        </tbody>
                                    </table>
                                </div>
                                <div class="bk-margin-5 btn-group" style="float: right">
                                    @Html.ShowPageNavigate((int)ViewData["pageIndexExecute"], (int)ViewData["pageSizeExecute"], (int)ViewData["totalExecute"])
                                </div>
                            </div>
                        </div>
                        <div id="edit" class="tab-pane updateProfile">
                            <div class="panel-body">
                                <div class="table-responsive">
                                    <table class="table table-hover">
                                        <thead>
                                            <tr>

                                                <th style="text-align: center">工作名称</th>
                                                <th style="text-align: center">创建日期</th>
                                                <th style="text-align: center">完成期限</th>
                                                <th style="text-align: center">结束时间</th>
                                                <th style="text-align: center">发布人</th>
                                                <th style="text-align: center">负责人</th>
                                                <th style="text-align: center">完成状态</th>

                                            </tr>
                                        </thead>
                                        <tbody>
                                            @{
                                                if (this.Model.DeskWorkYes.Tables[0].Rows.Count != 0)
                                                {
                                                    for (int i = 0; i < this.Model.DeskWorkYes.Tables[0].Rows.Count; i++)
                                                    {
                                                        var item = this.Model.DeskWorkYes.Tables[0].Rows[i];
                                                <tr>

                                                   @* @if (ViewBag.IsAdmin == true)
                                                    {
                                                        <td style="text-align: center"><a href="@Url.Action("CompileDeskWork", "DeskWork", new { area = "DepartmentArea", projectId = item["DESKWORK_ID"] })">@item["DESKWORK_NAME"]</a></td>
                                                    }*@
                                                   @* @if (ViewBag.IsAdmin == false)
                                                    {
                                                        *@<td style="text-align: center;color:black">@item["DESKWORK_NAME"]</td>
                                               @*     }*@
                                                    <td style="text-align: center;color:black">@Convert.ToDateTime(item["DESKWORK_CREATETIME"]).ToString("yyyy-MM-dd")</td>
                                                    <td style="text-align: center;color:black">@Convert.ToDateTime(item["DESKWORK_DEADINE"]).ToString("yyyy-MM-dd")</td>
                                                    <td style="text-align: center;color:black">@Convert.ToDateTime(item["DESKWORK_OVERTIME"]).ToString("yyyy-MM-dd")</td>
                                                    <td style="text-align: center;color:black">@item["DESKWORK_FOUNDER"]</td>
                                                    <td style="text-align: center;color:black">@item["DESKWORK_PRINCIPAL"]</td>
                                                     @if (Convert.ToDateTime(item["DESKWORK_DEADINE"]).Subtract(Convert.ToDateTime(item["DESKWORK_OVERTIME"])).Days >= 0)
                                                     {
                                                             <td  style="text-align:center;color:black"> <a href="#" title="按时完成"><img src="~/Assets/img/green_doing.gif"/> </a></td> 
                                                     }
                                                      @if (Convert.ToDateTime(item["DESKWORK_DEADINE"]).Subtract(Convert.ToDateTime(item["DESKWORK_OVERTIME"])).Days < 0)
                                                      {
                                                              <td style="text-align:center;color:black"><a href="#" title="工作完成已超期"><img src="~/Assets/img/red_over.gif"/> </a></td> 
                                                      }
                                                </tr>
                                                    }
                                                }
                                            }


                                        </tbody>
                                    </table>
                                </div>
                                <div class="bk-margin-5 btn-group" style="float: right">
                                    @Html.ShowPageNavigate((int)ViewData["pageIndexFinish"], (int)ViewData["pageSizeFinish"], (int)ViewData["totalFinish"])
                                </div>
                            </div>
                        </div>
                         <div id="dai" class="tab-pane updateProfile">
                            <div class="panel-body">
                                <div class="table-responsive">
                                    <table class="table table-hover">
                                        <thead>
                                            <tr>

                                                <th style="text-align: center">工作名称</th>
                                                <th style="text-align: center">创建日期</th>
                                                <th style="text-align: center">完成期限</th>
                                                <th style="text-align: center">发布人</th>
                                                <th style="text-align: center">负责人</th>
                                                <th style="text-align: center">完成状态</th>
                                                <th style="text-align: center">操作</th>
                                            </tr>
                                        </thead>
                                        <tbody>


                                            @if (ViewBag.DAI != null)
                                            {
                                                foreach (ProjectDeskWorkViewModel item in ViewBag.DAI)
                                                {
                                                     <tr>
                                                      
                                                    <td style="text-align: center"><a style="color:blue" href="@Url.Action("CompileDeskWork", "DeskWork", new { area = "DepartmentArea", projectId = item.DESKWORK_ID })">@item.DESKWORK_NAME</a></td>
                                                    <td style="text-align: center;color:black">@item.DESKWORK_CREATETIME.ToString("yyyy-MM-dd")</td>
                                                    <td style="text-align: center;color:black">@item.DESKWORK_DEADINE.ToString("yyyy-MM-dd")</td>
                                                    <td style="text-align: center;color:black">@item.DESKWORK_FOUNDER</td>
                                                    <td style="text-align: center;color:black">@item.DESKWORK_PRINCIPAL</td>
                                                    @if (item.DESKWORK_DEADINE.Subtract(DateTime.Now).Days > 3)
                                                    {
                                                         <td style="text-align:center;color:black"> <a href="#" title="工作正在办理"><img src="~/Assets/img/green_doing.gif"/> </a></td> 
                                                    }
                                                     @if (item.DESKWORK_DEADINE.Subtract(DateTime.Now).Days >= 0 && item.DESKWORK_DEADINE.Subtract(DateTime.Now).Days < 3)
                                                     {
                                                             <td style="text-align:center;color:black"><a href="#" title="剩余时间少于三天"><img src="~/Assets/img/yellew_three.gif"/> </a></td> 
                                                     }
                                                      @if (item.DESKWORK_DEADINE.Subtract(DateTime.Now).Days < 0)
                                                      {
                                                              <td style="text-align:center;color:black"><a href="#" title="工作时间已经超期"><img src="~/Assets/img/red_over.gif"/> </a></td> 
                                                      }
                                                         @if (item.DESKWORK_EDITOR == 1)
                                                         {
                                                              <td></td>   
                                                         }
                                                       @if (item.DESKWORK_EDITOR == 2)
                                                       {
                                                          <td style="text-align: center">   <a onclick="getid('@item.DESKWORK_ID')" data-toggle="modal" data-target="#tijiao"  style="color:blue">&nbsp;&nbsp;提交&nbsp;&nbsp;</a> </td>
                                                       }

                                                </tr>
                                                     
                                                }
                                            }

                                        </tbody>
                                    </table>
                                </div>
                                <div class="bk-margin-5 btn-group" style="float: right">
                                @*    @Html.ShowPageNavigate((int)ViewData["pageIndexExecute"], (int)ViewData["pageSizeExecute"], (int)ViewData["totalFinish"])*@
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>




<!--新增 模态框（Modal） -->

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <link href="~/Assets/plugins/bootstrap-select/bootstrap-select.min.css" rel="stylesheet" />
    <script src="~/Assets/plugins/bootstrap-select/bootstrap-select.min.js"></script>
    <link href="~/Assets/plugins/bootstrap-datepicker/css/datepicker3.css" rel="stylesheet" />
    <link href="~/Assets/plugins/bootstrap-datepicker/css/datepicker-theme.css" rel="stylesheet" />
    <script src="~/Assets/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
    <script src="~/Assets/plugins/chosen/chosen.jquery.min.js"></script>
    <script src="~/Assets/js/pages/form-elements.js"></script>


    <script>
        $(document).ready(function () {
            $("#deskWork_id").validate({
                rules: {
                    tb_WorkName: { required: true },
                    tb_Describe: { required: true },
                },
                messages: {
                    tb_WorkName: { required: "工作名称不能为空" },
                    tb_Describe: { required: "描述不能为空" },
                },
                errorPlacement: function (error, element) {
                    error.appendTo(element.next("span.workName_class"));
                    error.appendTo(element.next("span.Describe_class"));
                },
            });
            $("span.workName_class").css("color", "red");
            $("span.Describe_class").css("color", "red");
        })

      
        window.onload = function () {
            //$("#datetimepicker").datepicker();
            $("#datetimepicker").datepicker({
                autoclose: true,
                pickerPosition: "bottom-right"
            });
        };
    </script>

    <style>
        .btn-default {
            color: #333;
            background-color: #FFF;
            border-color: #CCC;
            height: 34px;
        }
    </style>
    <div class="modal-dialog">
        <div class="modal-content">
            <form id="deskWork_id" action="@Url.Action("CreateProject", "DeskWork", new { area = "DepartmentArea" })" method="POST">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModalLabel">增加科室工作</h4>
                </div>
                <div id="div_CreateProject" class="modal-body">
                    <div class="row">
                        <label class="col-md-3 control-label" for="text-input">工作名称</label>
                        <div class="col-md-9">
                            <input id="text-input" style="border-color: cornflowerblue" name="tb_WorkName" class="form-control" placeholder="Text" type="text">
                            <span class="workName_class"></span>
                        </div>
                    </div>
                    <br />

            @*        <div class="row">
                        <label class="col-md-3 control-label" for="text-input">工作编号</label>
                        <div class="col-md-9">
                            <input id="text-input1" readonly="true" value="@DateTime.Now.Year@DateTime.Now.Month@DateTime.Now.Day@DateTime.Now.Hour@DateTime.Now.Minute@DateTime.Now.Second" style="border-color: cornflowerblue" name="tb_WorkNO" class="form-control" placeholder="Text" type="text">
                            <span class="workName_class"></span>
                        </div>
                    </div>*@
                    <br />

                    <div class="row">
                        <label class="col-md-3 control-label">负责人：</label>
                        <div class="col-md-9" style="max-height: 34px">
                            <select name="select_WorkLeader" id="select_ProjectLeader" class="form-control selectpicker">
                                @{
                                    List<UserInfoViewModel> userList = (List<UserInfoViewModel>)TempData["UserList"];
                                    if (userList != null)
                                    {
                                        for (int i = 0; i < userList.Count(); i++)
                                        {
                                            var item = userList[i];
                                    <option value="@item.UserId">@item.UserName</option>
                                        }
                                    }
                                }
                            </select>
                        </div>
                    </div>

                    <br />
                    <div class="row">
                        <label class="col-md-3 control-label">完成期限：</label>
                        <div class="col-md-9">
                            <div class="input-append date" id="datetimepicker" data-date="@DateTime.Now.ToString("yyyy-MM-dd")" data-date-format="yyyy-mm-dd">
                                <input  id="t_BTime"  name="tb_BTime" style="border-color: cornflowerblue" class="form-control" size="10" type="text" value="@DateTime.Now.ToString("yyyy-MM-dd")">
                                <span class="add-on"><i class="icon-th"></i></span>
                            </div>
                            <span class="span_DevelopDescription"></span>
                        </div>
                    </div>

                         <br />

                    <div class="row">
                        <label class="col-md-3 control-label">发布人：</label>
                        <div class="col-md-9" style="max-height: 34px">
                            <input id="text-input" readonly="true" value="@ViewBag.myName" style="border-color: cornflowerblue" name="select_WorkEmp" class="form-control" placeholder="Text" type="text">
                        </div>
                    </div>
                    <br />

                    <div class="row">
                        <label class="col-md-3 control-label" for="text-input">工作内容描述：</label>
                        <div class="col-md-9">
                            <textarea id="textarea-input" name="tb_Describe" rows="5" class="form-control" placeholder="Content.."></textarea>
                            <span class="Describe_class"></span>
                        </div>
                    </div>
                    <br />

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">
                        关闭
                    </button>
                    <input type="submit" value="确认发布" class="btn btn-primary" />
                </div>
            </form>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal -->
</div>






@*提交工作*@
<script>
    function getid(bugId) {
      
        $.ajax({
            type: "POST",
            //url: "/KSManager/DepartmentArea/DeskWork/TiJiao",
            url:'@Url.Action("TiJiao","DeskWork",new{area="DepartmentArea"})',
            data: "roleId=" + bugId,
            error: function () { alert("服务器出错！"); },
            success: function (data) {
                $("#JILU").val(data["DESKWORK_ID"]);
            }
        });
    }
</script>


<div class="modal fade" id="tijiao" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
            </div>
            <form enctype="multipart/form-data" action="@Url.Action("InserJiLu", "DeskWork", new { area = "DepartmentArea" })", method="POST" >

                <div class="modal-body">
                    
                       <div class="row">
                        <label class="col-md-3 control-label" for="text-input">工作总结：</label>
                        <textarea   name="tb_Describe" rows="5" class="form-control" placeholder="Content.."></textarea>
                    </div>
                    <br />
                    <div class="row">
                        <label class="col-md-3 control-label" for="text-input">确定提交么？</label>
                           <input type="hidden" id="JILU" name="dai_work_idd" value="" />
                    </div>
                    <br />
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">
                        关闭
                    </button>
                    <input type="submit" value="确定" class="btn btn-primary" />
                </div>

            </form>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal -->
</div>